<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>字符串右移</title>
    <script>
      //字符串右移
      function rightchange(char, n) {
        var result = char;
        var i = 1;
        while (i <= n) {
          result = result.substr(-1) + result.slice(0, -1);
          i++;
        }
        console.log(result);
        // return result
      }
      rightchange("abcdefg", 2); //fgabcde
    </script>
  </head>
  <body></body>
</html>
